package com.zlb.app.modules.quartz.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zlb.app.modules.quartz.entity.JobLog;
import com.zlb.app.modules.quartz.mapper.JobLogMapper;
import com.zlb.app.modules.quartz.service.IJobLogService;
import com.zlb.app.utils.Assert;
import com.zlb.app.utils.PageUtil;
import org.springframework.stereotype.Service;

/**
 * @Desc 定时任务调度日志表 业务实现层
 * @Author zWX1367238
 * @Date 2024-08-27 11:57:56
 */
@Service
public class JobLogServiceImpl extends ServiceImpl<JobLogMapper, JobLog> implements IJobLogService {

    @Override
    public IPage<JobLog> pages(Long id) {
        Assert.isNull(id, "任务ID不能为空");
        LambdaQueryWrapper<JobLog> wrapper = Wrappers.lambdaQuery(JobLog.class)
                                                               .eq(JobLog::getJobId, id)
                                                               .orderByDesc(JobLog::getUpdateTime);
        return this.page(PageUtil.buildPage(JobLog.class), wrapper);
    }

}
